﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Roton
{
    /// <summary>
    /// Roton video output Component.
    /// </summary>
    sealed public partial class ManagedVideo : Control, IVideo
    {
        /// <summary>
        /// Create a video control that utilizes the .NET framework only.
        /// </summary>
        public ManagedVideo()
        {
            InitializeComponent();
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.FixedHeight, true);
            SetStyle(ControlStyles.FixedWidth, true);
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            //base.OnPaint(pe);
            if (Renderer != null && Renderer.Bitmap != null)
                pe.Graphics.DrawImage(Renderer.Bitmap, (int)0, (int)0);
        }

        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            //base.OnPaintBackground(pevent);
        }

        VideoRenderer Renderer { get; set; }

        public void SetChar(Point position, int value)
        {
            Renderer.SetChar(position, value);
        }

        public void SetColor(Point position, int value)
        {
            Renderer.SetColor(position, value);
        }

        public void SetCursorColor(int value)
        {
            Renderer.SetCursorColor(value);
        }

        public void SetCursorPosition(Point position)
        {
            Renderer.SetCursorPosition(position);
        }

        public void SetScreenSize(Size size)
        {
            Renderer.SetScreenSize(size);
        }

        public void SetWideMode(bool enabled)
        {
            Renderer.SetWideMode(enabled);
        }

        public void Write(string text)
        {
            Renderer.Write(text);
        }
    }
}
